﻿#region Vương văn hùng
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data.SqlClient;
using System.Data;
using System.Collections;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;

using DataAccess;
using Entities;
using Common;

namespace BusinessLogic
{
    static class Cong_Tru_KhoHang
    {
        public static int CongKhoHang(string MaKho, string MaHangHoa,string SoLuong)
        {
            try
            {
                SqlConnection cn = DataAccess.Connection.OpenConnection();
                SqlCommand cmd = new SqlCommand("exec sp_CongKho @MaKho,@MaHangHoa,@SoLuong", cn);
                cmd.Parameters.Add("MaKho", SqlDbType.NVarChar).Value = MaKho;
                cmd.Parameters.Add("MaHangHoa", SqlDbType.VarChar).Value = MaHangHoa;
                cmd.Parameters.Add("SoLuong", SqlDbType.Float).Value = SoLuong;
                return cmd.ExecuteNonQuery();
                cmd.Connection.Dispose();
                cn.Close();
                DataAccess.Connection.CloseConnection();
            }
            catch (Exception)
            {
                return 0;
            } 
        }
        public static int TruKhoHang(string MaKho, string MaHangHoa, string SoLuong)
        {
            try
            {
                SqlConnection cn = DataAccess.Connection.OpenConnection();
                SqlCommand cmd = new SqlCommand("exec sp_TruKho @MaKho,@MaHangHoa,@SoLuong", cn);
                cmd.Parameters.Add("MaKho", SqlDbType.NVarChar).Value = MaKho;
                cmd.Parameters.Add("MaHangHoa", SqlDbType.VarChar).Value = MaHangHoa;
                cmd.Parameters.Add("SoLuong", SqlDbType.Float).Value = SoLuong;
                return cmd.ExecuteNonQuery();
                cmd.Connection.Dispose();
                cn.Close();
                DataAccess.Connection.CloseConnection();
            }
            catch (Exception)
            {
                return 0;
            } 
        }
    }
}
#endregion
